package demo;

import cn.hutool.json.JSONUtil;

public class Test4 {
    public static void main(String[] args) {
        // 1、将对象转换成json字符串
        stu s1 = new stu();
        s1.setId(3);
        s1.setName("张三");
        s1.setAge(25);
        String str = JSONUtil.toJsonStr(s1);
        System.out.println(str);

        // 2、将json字符串转换成jvabean对象
        String s2 = "{\"id\":3,\"name\":\"张三\",\"age\":25}";
        stu stu = JSONUtil.toBean(s2, stu.class);
        System.out.println(stu);
    }
}
